package Homework;

public class PrintNumber extends Thread{
	Object lock;
	IsChild isNum;
	int count = 0;
	
	public PrintNumber(Object lock, IsChild isNum) {
		super();
		this.lock = lock;
		this.isNum = isNum;
	}

	@Override
	public void run() {
		while(true){
			synchronized (lock) {
				if(isNum.getLunshu()!=0){
					count++;
					System.out.print(count);
					try {
						sleep(100);
					} catch (InterruptedException e1) {
						e1.printStackTrace();
					}
					count++;
					System.out.print(count);
					try {
						sleep(100);
					} catch (InterruptedException e1) {
						e1.printStackTrace();
					}
					lock.notify();
					try {
						lock.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}else{
					lock.notify();
					break;
				}
			}
		}
	}
			
}
